#ifndef GETLIVEINFOHELPER_H
#define GETLIVEINFOHELPER_H

#include "liverecordertype.h"
#include <QDateTime>
#include <QObject>
#include <QPointer>

class LiveInfoView;
class LiveViewManager;

class GetLiveInfoHelper : public QObject
{
    Q_OBJECT
public:
    explicit GetLiveInfoHelper(LiveViewManager* view_mgr, QObject* parent = nullptr);

    int get(int platform, const QString& presenter_platform_id, const LiveHandler& handler);
    void cancel(int id);

private:
    struct Request
    {
        int id;
        int platform;
        QString presenter_platform_id;
        LiveHandler handler;
        QDateTime start_time;
        QPointer<LiveInfoView> view;
    };

    void onGetLiveInfo(int presenter, const QString& args);
    void startNextRequest();

    LiveViewManager* view_mgr_;
    QList<Request> requests_;
    QList<Request> currents_;
};

#endif // GETLIVEINFOHELPER_H
